package com.ibeeking.found.open.api.feign.fallback;

import com.ibeeking.found.open.api.common.param.cop.CopDepartmentParam;
import com.ibeeking.found.open.api.common.param.cop.CopEmployeeParam;
import com.ibeeking.found.open.api.feign.CopFeignClient;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
@Slf4j
public class CopFeignFallbackFactory implements FallbackFactory<CopFeignClient> {

    @Override
    public CopFeignClient create(Throwable throwable) {

        return new CopFeignClient() {
            @Override
            public ResponseResult<Integer> batchInsertDepartmentListFromWxCp(List<CopDepartmentParam> params) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入部门信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> insertDepartmentFromWxCp(CopDepartmentParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入部门信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> updateDepartmentFromWxCp(CopDepartmentParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入部门信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> deleteDepartmentFromWxCp(Long tenantId, Long id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信删除部门信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> batchInsertEmployeeListFromWxCp(List<CopEmployeeParam> params) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入员工信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> insertEmployeeFromWxCp(CopEmployeeParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入员工信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> updateEmployeeFromWxCp(CopEmployeeParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信导入员工信息失败。", null);
            }

            @Override
            public ResponseResult<Integer> deleteEmployeeFromWxCp(Long tenantId, Long id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，从企业微信删除员工信息失败。", null);
            }

        };
    }
}
